<template>
	<f7-page>
		<f7-view id="login-screen">
			<img src="../../static/img/mipmap-hdpi/ic_login_head.png" class="title_img" />
			<f7-page class='page lineH1-2'>

				<f7-login-screen-title class="fontS20">常熟敬老院<br><small>移动护理</small></f7-login-screen-title>
				<f7-list id="ul">
					<f7-list-item>
						<f7-label>账号</f7-label>
						<f7-input placeholder="账号" type="number" :value="config.Enum" @input="config.Enum = $event.target.value"></f7-input>
					</f7-list-item>
					<f7-list-item>
						<f7-label>密码</f7-label>
						<f7-input placeholder="密码" type="password" :value="config.password" @input="config.password = $event.target.value"></f7-input>
					</f7-list-item>
				</f7-list>
				<f7-list>
					<button class="col button button-fill color-blue" @click="in_">登 录</button>
				</f7-list>
				<p class="text-align-center">扫描工牌可直接登录</p>
			</f7-page>
		</f7-view>
	</f7-page>
</template>

<script>
	import { AndroidControl, JavascriptInterface } from "@/utils/AndroidBridge";
	export default {
		created: function() {
			var that=this;
			global.COURSES.that = this;
			//监听NFC扫描事件
			new JavascriptInterface().jsNFCReceiver((tag) => {
				// let tagArr = tag.split(":");
				// alert(tagArr[0])
				that.$post(global.COURSES.path + '/employees/login', {'RFID':tag}).then(message => {
					console.log(message)
					if(message.code==0){
						let userInfo = JSON.parse(message.data)
						global.COURSES.loginMessage = message.data;
						global.COURSES.careId = userInfo.id;
						global.COURSES.careName = userInfo.name;
						global.COURSES.isMonitor = userInfo.isMonitor;
						global.COURSES.schedulinfo = userInfo.schedulinfo;
						global.COURSES.spid = userInfo.spid;
						that.$f7.views.main.router.navigate('/index/');
					}
				})
			});
		},
		data() {
			return {
				// config: {
				// 	Enum: 22222222222,
				// 	password: 123456
				// }
				config: {
					Enum: 12345678900,
					password: 123456
				}
			}
		},
		methods: {
			in_: function() {
				var that=this;
				if(!that.config.Enum || !that.config.password){
					alert('缺少用户名或密码！');
					return;
				}
				that.$post(global.COURSES.path + '/employees/login', that.config).then(message => {
					console.log(message)
					if(message.code==0){
						let userInfo = JSON.parse(message.data)
						global.COURSES.loginMessage = message.data;
						global.COURSES.careId = userInfo.id;
						global.COURSES.careName = userInfo.name;
						global.COURSES.isMonitor = userInfo.isMonitor;
						global.COURSES.schedulinfo = userInfo.schedulinfo;
						global.COURSES.spid = userInfo.spid;
						
						that.$f7.views.main.router.navigate('/index/');
					}
				})
				
			},
		}

	}
</script>
<style>
	#login-screen {
		background: url(../../static/img/drawable-xhdpi/bg_login.png) no-repeat !important;
		background-size: 100% 100%;
	}
	#login-screen .page-content{
		background-color: transparent;
		position: relative;
	}
	.fontS20{
		font-size: 20px!important;
	}
	#login-screen .list{
		margin: 10px 0;
	}
	#login-screen .page{
		bottom: 0;
		right: 0;
		width: 80%;
		margin: 100px auto;
		padding: 20px 10px 10px 10px;
		border-radius: 5px;
		height: 316px;
		box-shadow: 0 0 10px rgba(255,255,255,.2);
	}
	#login-screen .page-content{
		position: relative;
	}
	.lineH1-2{
		line-height: 1.2;
	}
	#login-screen #ul ul:before,#login-screen #ul ul:after{
		background-color: transparent;
	}
	.title_img{
		position: absolute;
		width: 80px;
		top: 55px;
		right: 0;
		left: 0;
		bottom: 0;
		margin: 0 auto;
		z-index: 9999;
	}
</style>
